<!doctype html>
<html class="no-js">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="description" content="">
  <meta name="keywords" content="">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>变压器油色谱三比值分析</title>

  <!-- Set render engine for 360 browser -->
  <meta name="renderer" content="webkit">

  <!-- No Baidu Siteapp-->
  <meta http-equiv="Cache-Control" content="no-siteapp"/>

  <link rel="icon" type="image/png" href="assets/i/favicon.png">

  <!-- Add to homescreen for Chrome on Android -->
  <meta name="mobile-web-app-capable" content="yes">
  <link rel="icon" sizes="192x192" href="assets/i/app-icon72x72@2x.png">

  <!-- Add to homescreen for Safari on iOS -->
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
  <meta name="apple-mobile-web-app-title" content="Amaze UI"/>
  <link rel="apple-touch-icon-precomposed" href="assets/i/app-icon72x72@2x.png">

  <!-- Tile icon for Win8 (144x144 + tile color) -->
  <meta name="msapplication-TileImage" content="assets/i/app-icon72x72@2x.png">
  <meta name="msapplication-TileColor" content="#0e90d2">

  <link rel="stylesheet" href="assets/css/amazeui.min.css">
  <link rel="stylesheet" href="assets/css/app.css">
</head>
<body>
  <div class="am-g am-g-fixed" style="margin-top:36px;">
    <div class="am-u-sm-6 am-u-end">
        <p style="font-size:21px;">变压器油色谱三比值分析</p>
    </div>
  </div>

  <!-- form view start-->
  <div class="am-container" style="margin-top:18px;">
      <div class="am-g">
          <div class="am-u-sm-1">
              <p>&nbsp;</p>
          </div>
          <div class="am-u-sm-8 am-u-end">
              <p>
                  请在下面分别输入色谱值:
              </p>
              <span class="" id="input_error1">
                  <input type="text" class="am-form-field am-radius" id="c2h2" value="" placeholder="输入C2H2">
              </span>
              <p>
              </p>
              <span class="" id="input_error2">
                  <input type="text" class="am-form-field am-radius" id="c2h4" value="" placeholder="输入C2H4">
              </span>
              <p>
              </p>
              <span class="" id="input_error3">
                  <input type="text" class="am-form-field am-radius" id="ch4" value="" placeholder="输入CH4">
              </span>
              <p>
              </p>
              <span class="" id="input_error4">
                  <input type="text" class="am-form-field am-radius" id="h2" value="" placeholder="输入H2">
              </span>
              <p>
              </p>
              <span class="" id="input_error5">
                  <input type="text" class="am-form-field am-radius" id="c2h6" value="" placeholder="输入C2H6">
              </span>
              <p>
              </p>
              <button type="button" id="start_compute" class="am-btn am-btn-secondary">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;计&nbsp;&nbsp;算&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</button>
          </div>
      </div>

      <br />
      <div class="am-g">
          <!-- 错误提示输出的容器 -->
          <div class="am-panel am-panel-success" style="display:none;" id="alert_box">
              <div class="am-panel-bd" id="alert_content"></div>
          </div>


          <!-- 应用执行结果的输出容器 -->
          <div class="am-panel am-panel-secondary" id="show_box" style="display:none;">
              <div class="am-panel-hd" id="show_content1"></div>
              <div class="am-panel-bd" id="show_content2">
                  
              </div>
          </div>
      </div>
  </div>

  <!-- form view end -->

  <!-- footer start -->
  <footer data-am-widget="footer" class="am-footer am-footer-default" data-am-footer="{  }">
    <div class="am-footer-miscs ">
      <p>感谢您的访问！</p>
      <p>CopyRight©2017 zengzhiying.net Inc.</p>
      <p><a href="http://www.miitbeian.gov.cn/" target="_blank">鲁ICP备14017209号-2</a></p>
    </div>
  </footer>
  <!-- footer end -->


  <!--[if (gte IE 9)|!(IE)]><!-->
  <script src="assets/js/jquery.min.js"></script>
  <!--<![endif]-->
  <!--[if lte IE 8 ]>
  <script src="http://libs.baidu.com/jquery/1.11.3/jquery.min.js"></script>
  <script src="http://cdn.staticfile.org/modernizr/2.8.3/modernizr.js"></script>
  <script src="assets/js/amazeui.ie8polyfill.min.js"></script>
  <![endif]-->
  <script src="assets/js/amazeui.min.js"></script>



  <!-- js验证逻辑 -->

  <script type="text/javascript">
    function average(a, b, c) {
      return (a + b + c)/3.0;
    }
    //查询Ajax事件
    $(document).ready(function() {
        $("#start_compute").click(function() {
            //提示信息初始化
            var alert_content = '<img src="./assets/i/landing.gif" >&nbsp;正在计算，请稍后...';
            $("#alert_content").html(alert_content);
            $("#alert_box").show();
            $("#input_error1").attr("class","");
            $("#input_error2").attr("class","");
            $("#input_error3").attr("class","");
            $("#input_error4").attr("class","");
            $("#input_error5").attr("class","");
            $("#show_box").hide();
            //js 简单验证逻辑 多个表单继续补充此处
            var c2h2 = $("#c2h2").val();
            var c2h4 = $("#c2h4").val();
            var ch4 = $("#ch4").val();
            var h2 = $("#h2").val();
            var c2h6 = $("#c2h6").val();

            var f_pattern = new RegExp('^(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*))$');
            if(c2h2 == '' || !f_pattern.test(c2h2)) {
                $("#input_error1").attr("class","am-form-error");
                $("#alert_content").html("C2H2输入错误！");
                return false;
            }
            if(c2h4 == '' || !f_pattern.test(c2h4)) {
                $("#input_error2").attr("class","am-form-error");
                $("#alert_content").html("C2H4输入错误！");
                return false;
            }
            if(ch4 == '' || !f_pattern.test(ch4)) {
                $("#input_error3").attr("class","am-form-error");
                $("#alert_content").html("CH4输入错误！");
                return false;
            }
            if(h2 == '' || !f_pattern.test(h2)) {
                $("#input_error4").attr("class","am-form-error");
                $("#alert_content").html("H2输入错误！");
                return false;
            }
            if(c2h6 == '' || !f_pattern.test(c2h6)) {
                $("#input_error5").attr("class","am-form-error");
                $("#alert_content").html("C2H6输入错误！");
                return false;
            }
            console.log("start compute.");

            c2h2 = parseFloat(c2h2);
            c2h4 = parseFloat(c2h4);
            ch4 = parseFloat(ch4);
            h2 = Number(h2);
            c2h6 = Number(c2h6);
            console.log("c2h2: " + c2h2);
            console.log("c2h4: " + c2h4);
            console.log("ch4: " + ch4);
            console.log("h2: " + h2);
            console.log("c2h6: " + c2h6);
            // 开始计算
            // 三比值计算
            var specific = new Array();
            specific[0] = c2h2/c2h4;
            specific[1] = ch4/h2;
            specific[2] = c2h4/c2h6;
            var specific_encode = new Array();
            // 编码处理
            for(var i = 0; i < specific.length; i++) {
              if(specific[i] < 0.1) {
                if(i == 2) {
                  specific_encode[i] = 0;
                } else {
                  specific_encode[i] = i;
                }
              } else if(specific[i] < 1) {
                if(i == 0) {
                  specific_encode[i] = 1;
                } else {
                  specific_encode[i] = 0;
                }
              } else if(specific[i] < 3) {
                if(i == 2) {
                  specific_encode[i] = 2;
                } else {
                  specific_encode[i] = 1;
                }
              } else {
                specific_encode[i] = 2;
              }
            }
            console.log(specific_encode);

            // 生成组合
            var result = new Array();
            // 1.
            result['001'] = new Array();
            result['001']['type'] = "低温过热（低于150℃）";
            result['001']['example'] = "绝缘导线过热，注意CO和CO2的含量，以及CO2/CO值";
            // 2.
            result['020'] = new Array();
            result['020']['type'] = "低温过热（150 ~ 300）℃";
            result['020']['example'] = "分接开关接触不良，引线夹件螺丝松动或接头焯接不良，涡流引起铜过热，铁心漏磁，局部短路，层间绝缘不良，铁心多点接地等";
            // 3. 
            result['021'] = new Array();
            result['021']['type'] = "中温过热（300 ~ 700）℃";
            result['021']['example'] = "分接开关接触不良，引线夹件螺丝松动或接头焯接不良，涡流引起铜过热，铁心漏磁，局部短路，层间绝缘不良，铁心多点接地等";
            // 4. 
            result['002'] = new Array();
            result['012'] = new Array();
            result['022'] = new Array();
            result['002']['type'] = result['012']['type'] = result['022']['type'] = "高温过热（高于700℃）";
            result['002']['example'] = result['012']['example'] = result['022']['example'] = "分接开关接触不良，引线夹件螺丝松动或接头焯接不良，涡流引起铜过热，铁心漏磁，局部短路，层间绝缘不良，铁心多点接地等";
            // 5. 
            result['010'] = new Array();
            result['010']['type'] = "局部放电";
            result['010']['example'] = "高温度、高含气量引起油中低能量密度的局部放电";
            // 6. 
            result['100'] = new Array();
            result['101'] = new Array();
            result['102'] = new Array();
            result['110'] = new Array();
            result['111'] = new Array();
            result['112'] = new Array();
            result['100']['type'] = "低能放电";
            result['101']['type'] = result['100']['type'];
            result['102']['type'] = result['100']['type'];
            result['110']['type'] = result['100']['type'];
            result['111']['type'] = result['100']['type'];
            result['112']['type'] = result['100']['type'];

            result['100']['example'] = "引线对电位未固定的部件之间连续火花放电，分接抽头引线和油隙闪络，不同电位之间的油中火花放电或悬浮电位之间的火花放电";
            result['101']['example'] = result['100']['example'];
            result['102']['example'] = result['100']['example'];
            result['110']['example'] = result['100']['example'];
            result['111']['example'] = result['100']['example'];
            result['112']['example'] = result['100']['example'];
            // 7. 
            result['120'] = new Array();
            result['121'] = new Array();
            result['122'] = new Array();
            result['120']['type'] = result['121']['type'] = result['122']['type'] = "低能放电兼过热";
            result['120']['example'] = result['121']['example'] = result['122']['example'] = result['100']['example'];
            // 8. 
            result['200'] = new Array();
            result['201'] = new Array();
            result['202'] = new Array();
            result['210'] = new Array();
            result['211'] = new Array();
            result['212'] = new Array();
            result['200']['type'] = "电弧放电";
            result['201']['type'] = result['202']['type'] = result['200']['type'];
            result['210']['type'] = result['211']['type'] = result['212']['type'] = result['200']['type'];
            result['200']['example'] = "线圈匝间、层间短路，相间闪络、分接头引线间油隙闪络、引线对箱壳放电、线圈熔断、分接开关飞弧、因环路电流引起电弧、引线对其他接地体放电等";
            result['201']['example'] = result['202']['example'] = result['200']['example'];
            result['210']['example'] = result['211']['example'] = result['212']['example'] = result['200']['example'];
            // 9.
            result['220'] = new Array();
            result['221'] = new Array();
            result['222'] = new Array();
            result['220']['type'] = result['221']['type'] = result['222']['type'] = "电弧放电兼过热";
            result['220']['example'] = result['221']['example'] = result['222']['example'] = result['200']['example'];

            var fault_keys = specific_encode.join("")
            if(result[fault_keys] == null) {
              $("#alert_box").hide();
              $("#show_content1").html("查表没有结果！请检查输入.");
              $("#show_box").show('slow');
              return;
            }

            $("#alert_box").hide();
            $("#show_content1").html("计算结果:");
            $("#show_content2").html("<span>故障类型： " + result[fault_keys]['type'] + " </span><br />");
            $("#show_content2").append("<br />故障实例（参考）： <span>" + result[fault_keys]['example'] + "</span><br />")
            $("#show_box").show('slow');
            return true;

            //jquery ajax 高层实现 异步回调
            // $.get("/webapps", {"input_text":input_text}, function(data) {
            //     $("#alert_box").hide();
            //     $("#show_content1").html("查询结果");
            //     $("#show_content2").html(data);
            //     $("#show_box").show('slow');
            //     return true;
            // });

        });
    });
  </script>
</body>
</html>